local sk__yuyou = fk.CreateSkill {

  name = "sk__yuyou",

  tags = { Skill.Compulsory, },

}



sk__yuyou:addEffect(fk.AfterCardsMove, {
  name = "sk__yuyou",
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(sk__yuyou.name) then
      for _, move in ipairs(data) do
        if move.to == player and move.toArea == Card.PlayerHand and #move.moveInfo > 1 then
          return true
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = {}
    for _, move in ipairs(data) do
      if move.to == player and move.toArea == Card.PlayerHand and #move.moveInfo > 1 then
        for _, info in ipairs(move.moveInfo) do
          table.insertIfNeed(cards, info.cardId)
        end
      end
    end
    local card = room:askForCard(player, 1, 1, false, sk__yuyou.name, false,
      ".|.|.|.|.|.|"..table.concat(cards, ","), "#sk__yuyou-ask")
    table.removeOne(cards, card[1])
    local n = #cards
    room:throwCard(cards, sk__yuyou.name, player, player)
    local targets = table.filter(room.alive_players, function(p)
      return p.gender == General.Male or p.gender == General.Bigender
    end)
    if player.dead or #targets == 0 then return end
    local to = room:askForChoosePlayers(player, table.map(targets, Util.IdMapper), 1, 1, "#sk__yuyou-choose:::"..n, sk__yuyou.name, true)
    if #to > 0 then
      to = room:getPlayerById(to[1])
      if #room:askForDiscard(to, n, n, true, sk__yuyou.name, true, ".", "#sk__yuyou-discard:::"..n) < n then
        room:loseHp(to, 1, sk__yuyou.name)
      end
    end
  end,
})

return sk__yuyou